#include "server.h"
#include "client.h"

using namespace std;

int main() {
    // 服务端
    TCPServer server(8888);
    if (!server.start()) {
        return -1;
    }
    if (!server.acceptclient()) {
        return -1;
    }

    string message;
    server >> message;
    cout << "Received from client: " << message << endl;
    server << "Hello from server!";

    // 客户端
    TCPClient client("127.0.0.1", 8888);
    if (!client.connectToServer()) {
        return -1;
    }
    client << "Hello from client!";
    client >> message;
    cout << "Received from server: " << message << endl;

    // 关闭连接
    server.closeserver();
    client.closeclient();

    return 0;
}